package com.felight.objectReadWrite;

/**
 * This class will write object into a file.
 */
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Externalizable;

public class Writefile {

	public static void main(String[] args) {

		try {
			FileOutputStream fo = new FileOutputStream("output1.txt");

			ObjectOutputStream os = new ObjectOutputStream(fo);
			Student st = new Student();
			st.name = "abc";
			st.perc = 90;
			os.writeObject(st); // this line will write object into the a file
			System.out.println("object is written");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
